##### My (demuredemeanor) offlineimaprc
# Uses tabstop=4; shiftwidth=4 tabs; foldmarker={{{,}}};
# https://notabug.org/demure/dotfiles
# legacy repo http://github.com/demure/dotfiles
# vim:set syntax=sh:

## This is heavily inspired by Mark H. Nichols's post
# http://zanshin.net/2015/01/19/teaching-a-homely-mutt-new-tricks/
#
# which in turn was inspired by Steve Losh's post
# http://stevelosh.com/blog/2012/10/the-homely-mutt/
#
# Aside from using my accounts, and eventually a few tweaks,
# I am /not/ using OS X's keychain...
# I am using pass now, which is working quite well
# https://github.com/sup-heliotrope/sup/wiki/Securely-Store-Password


### Main Settings ### {{{
[general]
#ui = ttyui
ui = blinkenlights
## ui = quiet
##accounts = root,sdf,gmail,emu
accounts = emu,sdf,gmail
pythonfile=~/.mutt/offlineimap.py
fsync = False
### End Main ### }}}

### sdf ### {{{
[Account sdf]
localrepository = sdf-Local
remoterepository = sdf-Remote
postsynchook = [ -e $HOME/.notmuch-config ] && notmuch new

[Repository sdf-Local]
type = Maildir
localfolders = ~/.mail/sdf

[Repository sdf-Remote]
## This is set due to an annoying error by the exparimental xoauth2
# https://bbs.archlinux.org/viewtopic.php?id=206424
auth_mechanisms = GSSAPI, CRAM-MD5, PLAIN, LOGIN
maxconnections = 3
type = IMAP
remoteuser = demure
remotehost = ma.sdf.org
remoteport = 993
ssl = yes
## temp setting due to https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=907079
## Left in place due to issue with MA cert size?
ssl_version = tls1_2
#cert_fingerprint = 5c3c0973316f28669c7c7f91dd3cc1698475e8b0ccb54267da99018bf5f2878018ef0d7ce1dad3868d57cc4be0d0c4c439c224403640b4eac0f03736f46dbe47
cert_fingerprint = 76ff9a3e19ed7e7b7a40d1ef2b82177a65d41d09419ba0a584b891e18eb03aa0967cddd649388b845e63501637d56f8653303396d6d6576ec0e69bb59b473ac9
remotepasseval = get_pass("mail-sdf-imap")
realdelete = True
### End sdf### }}}

### gmail ### {{{
[Account gmail]
localrepository = gmail-Local
remoterepository = gmail-Remote
## Needs GmailMaildir set
synclabels = yes
## Where sync labels are stored
labelsheader = X-Keywords
postsynchook = [ -e $HOME/.notmuch-config ] && notmuch new

[Repository gmail-Local]
type = GmailMaildir
localfolders = ~/.mail/gmail
nametrans = lambda folder: {'drafts':  '[Gmail]/Drafts',
                            'sent':    '[Gmail]/Sent Mail',
                            'flagged': '[Gmail]/Starred',
                            'trash':   '[Gmail]/Trash',
                            'archive': '[Gmail]/All Mail',
                            }.get(folder, folder)

[Repository gmail-Remote]
## This is set due to an annoying error by the exparimental xoauth2
# https://bbs.archlinux.org/viewtopic.php?id=206424
auth_mechanisms = GSSAPI, CRAM-MD5, PLAIN, LOGIN
maxconnections = 1
type = Gmail
remoteuser = demuredemeanor@gmail.com
ssl = yes
sslcacertfile = /etc/ssl/certs/ca-certificates.crt
remotepasseval = get_pass("mail-gmail")
## This setting removes mail for good, default of 'no' just strips gmail label (think inbox)
realdelete = True
nametrans = lambda folder: {'[Gmail]/Drafts':    'drafts',
                            '[Gmail]/Sent Mail': 'sent',
                            '[Gmail]/Starred':   'flagged',
                            '[Gmail]/Trash':     'trash',
                            '[Gmail]/All Mail':  'archive',
                            }.get(folder, folder)
folderfilter = lambda folder: folder in ['[Gmail]/Drafts',
                                        '[Gmail]/Sent Mail',
                                        '[Gmail]/Starred',
                                        '[Gmail]/Trash',
                                        '[Gmail]/All Mail',
                                        'INBOX',
                                        'People',
                                        'Orders',
                                        'News Letters',
                                        ]
### End gmail ### }}}

### EMU ### {{{
[Account emu]
localrepository = emu-Local
remoterepository = emu-Remote
postsynchook = [ -e $HOME/.notmuch-config ] && notmuch new

[Repository emu-Local]
type = Maildir
localfolders = ~/.mail/emu
nametrans = lambda folder: {'drafts':  '[Gmail]/Drafts',
                            'sent':    '[Gmail]/Sent Mail',
                            'flagged': '[Gmail]/Starred',
                            'trash':   '[Gmail]/Trash',
                            'archive': '[Gmail]/All Mail',
                            }.get(folder, folder)

[Repository emu-Remote]
## This is set due to an annoying error by the exparimental xoauth2
# https://bbs.archlinux.org/viewtopic.php?id=206424
auth_mechanisms = GSSAPI, CRAM-MD5, PLAIN, LOGIN
maxconnections = 1
type = Gmail
remoteuser = amcbean@emich.edu
ssl = yes
sslcacertfile = /etc/ssl/certs/ca-certificates.crt
remotepasseval = get_pass("mail-emu")
realdelete = True
nametrans = lambda folder: {'[Gmail]/Drafts':    'drafts',
                            '[Gmail]/Sent Mail': 'sent',
                            '[Gmail]/Starred':   'flagged',
                            '[Gmail]/Trash':     'trash',
                            '[Gmail]/All Mail':  'archive',
                            }.get(folder, folder)
folderfilter = lambda folder: folder in ['[Gmail]/Drafts',
                                        '[Gmail]/Sent Mail',
                                        '[Gmail]/Starred',
                                        '[Gmail]/Trash',
                                        '[Gmail]/All Mail',
                                        'INBOX',
                                        ]
### End EMU ### }}}
